﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/MasterPage.Master" AutoEventWireup="true" CodeBehind="ManageAgencies.aspx.cs" Inherits="DrivingCRM.Views.Private.CRM.ManageAgencies" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="banniere" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="nav" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="contenu" runat="server">
    <h2>Gestion des Agences</h2>
    <asp:ListView ID="LV_Agencies" runat="server" DataKeyNames="IdAgency" 
        DataSourceID="DS_Agencies" OnItemCanceling="LV_Agencies_ItemCanceling" 
        OnItemInserting="LV_Agencies_ItemInserting" OnItemUpdating="LV_AgenciesItemUpdating">
        <AlternatingItemTemplate>
            <td runat="server" style="background-color:#FFF8DC;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Nom de l'agence:</td>
                        <td><asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /></td>
                    </tr>
                    <tr>
                        <td>Description:</td>
                        <td><asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' /></td>
                    </tr>
                    <tr>
                        <td>Adresse:</td>
                        <td><asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address.CompleteAddress") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Supprimer" /></td>
                        <td><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Modifier" /></td>
                    </tr>
                </table>
            </td>
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <td runat="server" style="background-color:#008A8C;color: #FFFFFF;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Nom de l'agence:</td>
                        <td><asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' /></td>
                    </tr>
                    <tr>
                        <td>Description:</td>
                        <td><asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' /></td>
                    </tr>
                    <tr>
                        <td>Adresse:</td>
                        <td><asp:DropDownList ID="DDL_Addresses" runat="server" 
                                 DataSourceID="DS_Addresses" 
                                 DataValueField="IdAdress" DataTextField="CompleteAddress" />
                                 <%--DataTextField='<%# DataBinder.Eval(Container.DataItem, "Number") + " "+ DataBinder.Eval(Container.DataItem, "StreetType")+" "+DataBinder.Eval(Container.DataItem, "ZipCode")+" "+DataBinder.Eval(Container.DataItem, "City") %>' />--%>
                            <asp:EntityDataSource ID="DS_Addresses" runat="server" 
                                ConnectionString="name=Model_DrivingCRMContainer" 
                                DefaultContainerName="Model_DrivingCRMContainer" EntitySetName="AddressSet" 
                                EntityTypeFilter="Address">
                            </asp:EntityDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Mettre à jour" /></td>
                        <td><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Annuler" /></td>
                    </tr>
                </table>
            </td>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table runat="server" 
                style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                <tr>
                    <td>
                        <h2>Aucune agence en base.</h2></td>
                </tr>
                <tr>
                    <td><asp:Button ID="B_AddAgency" runat="server" Text="Ajouter une agence" OnClick="B_AddAgency_Click" /></td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <EmptyItemTemplate>
<td runat="server" />
        </EmptyItemTemplate>
        <GroupTemplate>
            <tr ID="itemPlaceholderContainer" runat="server">
                <td ID="itemPlaceholder" runat="server">
                </td>
            </tr>
        </GroupTemplate>
        <InsertItemTemplate>
            <td runat="server" style="">
                <table class="Table_ItemList">
                    <tr>
                        <td>Nom de l'agence:</td>
                        <td><asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' /></td>
                    </tr>
                    <tr>
                        <td>Description:</td>
                        <td><asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' /></td>
                    </tr>
                    <tr>
                        <td>Adresse:</td>
                        <td><asp:DropDownList ID="DDL_Addresses" runat="server" 
                                 DataSourceID="DS_Addresses" 
                                 DataValueField="IdAdress"
                                 DataTextField='CompleteAddress' />
                            <asp:EntityDataSource ID="DS_Addresses" runat="server" 
                                ConnectionString="name=Model_DrivingCRMContainer" 
                                DefaultContainerName="Model_DrivingCRMContainer" 
                                EntitySetName="AddressSet" EntityTypeFilter="Address"
                                EnableFlattening="False" Include="StreetType"
                                ><%--Select="it.IdAdress AS IdAdress, it.Number + ' ' it.StreetType.Type + ' ' + it.StreetName + ' ' + it.ZipCode + ' ' + it.City AS CompleteAddress"--%>
                            </asp:EntityDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Ajouter" /></td>
                        <td><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Annuler" /></td>
                    </tr>
                </table>
            </td>
        </InsertItemTemplate>
        <ItemTemplate>
            <td runat="server" style="background-color:#DCDCDC;color: #000000;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Nom de l'agence:</td>
                        <td><asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /></td>
                    </tr>
                    <tr>
                        <td>Description:</td>
                        <td><asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' /></td>
                    </tr>
                    <tr>
                        <td>Adresse:</td>
                        <td><asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address.CompleteAddress") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Supprimer" /></td>
                        <td><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Modifier" /></td>
                    </tr>
                </table>
            </td>
        </ItemTemplate>
        <LayoutTemplate>
            <table runat="server">
                <tr runat="server">
                    <td runat="server">
                        <table ID="groupPlaceholderContainer" runat="server" border="1" 
                            style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <tr ID="groupPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr runat="server">
                    <td runat="server"><asp:Button ID="B_AddAgency" runat="server" Text="Ajouter une agence" OnClick="B_AddAgency_Click" /></td>
                </tr>
                <tr runat="server">
                    <td runat="server" 
                        style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                        <asp:DataPager ID="DataPager1" runat="server" PageSize="12">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" PreviousPageText="Précédent" FirstPageText="Première page" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" NextPageText="Suivant" LastPageText="Dernière page" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:EntityDataSource ID="DS_Agencies" runat="server" 
        ConnectionString="name=Model_DrivingCRMContainer" 
        DefaultContainerName="Model_DrivingCRMContainer" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" EntitySetName="AgencySet" 
        EntityTypeFilter="Agency" EnableFlattening="False" Include="Address">
    </asp:EntityDataSource>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="footer" runat="server">
</asp:Content>
